import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  // 用户信息
  userInfo: {
    age: "",
    bankFlag: "",
    email: "906446244@qq.com",
    faceFlag: "",
    headPic: "",
    height: "",
    idCardFlag: "",
    invitationCode: "",
    jiGuangPwd: "",
    nickName: "",
    sessionId: "",
    sex: "",
    userId: "",
    userName: "",
    weight: "",
    whetherBingWeChat: "",
  },
  // 用户登录状态
  isLogin: false
};

const userSlice = createSlice({
  name: "user",
  initialState,
  reducers: {
    loginSuccess(state, action) {
      state.isLogin = true;
      state.userInfo = action.payload
    },
    quitLogin(state) {
      state.isLogin = false;
      state.userInfo = initialState.userInfo
    }
  }
});


export default userSlice
// 抛出 action
export const { loginSuccess, quitLogin } = userSlice.actions
